﻿using System;
using System.Collections.Generic;
using System.Text;

namespace daSyntaxAnalyser.SyntaxTree
{
    using daBase.Objects;

    public class RecordElement : SyntaxTreeElement, ITypeElement
    {
        private List<ISectionElementElement> elements;

        public List<ISectionElementElement> Elements { get { return elements; } set { elements = value; } }

        public RecordElement(TokenInfo StartInfo, List<ISectionElementElement> Elements, List<TokenInfo> Comments)
            : base(StartInfo, Comments)
        {
            elements = Elements;
        }

        public override string ToString()
        {
            return string.Format("record{0}\r\nend", ((elements != null) && (elements.Count > 0)) ? Tabulate(elements.Join("\r\n")) : string.Empty);
        }

        protected override IEnumerator<ISyntaxTreeElement> CreateEnumerator()
        {
            if (elements != null)
                foreach (ISectionElementElement element in elements)
                    yield return element;
        }
    }
}
